package com.wechatapp.mengyao.poetry.service.impl;

import com.wechatapp.mengyao.poetry.entity.Category;
import com.wechatapp.mengyao.poetry.mapper.CategoryMapper;
import com.wechatapp.mengyao.poetry.service.CategoryService;
import com.wechatapp.mengyao.poetry.vo.CategoryView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yanghuaxu
 * @date 2025/7/5 16:36
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<CategoryView> getAllCategoryList(String mediaType) {
        Category condition=new Category();
        condition.setMediaType(mediaType);
        return categoryMapper.select(condition).stream().map(c -> new CategoryView(c.getId(), c.getName(), c.getMediaType())).collect(Collectors.toList());
    }
}
